import requests
import json
import execjs


def mm():
    with open('t1.js', 'r', encoding='utf-8') as f:
        jstext = f.read()
    ctx = execjs.compile(jstext)
    result = ctx.call('get_m')
    return result


kv = {
    'User-Agent': 'yuanrenxue.project',
    'cookie': 'sessionid=jzc0m6y5yl7mazc36aqfyd5c0mg721t0'
}


def mian(i, m):
    global num
    print(m)
    r = requests.get('http://match.yuanrenxue.com/api/match/1?page=' + str(i) + '&m=' + str(m), headers=kv)
    l = json.loads(r.text)
    for i in l['data']:
        # print(i['value'])
        num.append(i['value'])


if __name__ == '__main__':
    num = []
    for i in range(1, 6):
        mian(i, mm())
    print(sum(num) / len(num))
